package com.njxxted.activiti.common.listener.process;

import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.activiti.engine.delegate.event.ActivitiVariableEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 描述：描述一个侦听引擎调度的类。(采用了模版模式)，所有任务监听器的实现都必须继承此类
 * <p>
 * 作者：Ostrich Hu
 * 时间：2019/8/13 14:12 星期二
 */
public abstract class BaseTemplateEventListener implements ActivitiEventListener {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void onEvent(ActivitiEvent event) {
        if (event.getType() == ActivitiEventType.VARIABLE_CREATED) {
            ActivitiVariableEvent variableEvent = (ActivitiVariableEvent) event;
            logger.debug("创建了变量名:{} , 变量值：{}", variableEvent.getVariableName(), variableEvent.getVariableValue());
        } else {
            logger.debug("Event received:{} ", event.getType());
        }
    }

    @Override
    public boolean isFailOnException() {
        logger.debug("Event isFailOnException");
        return false;
    }
}
